package com.qiyi.player.wonder.plugins.tips.model
{
   import org.puremvc.as3.patterns.proxy.Proxy;
   import com.qiyi.player.wonder.common.status.IStatus;
   import com.qiyi.player.wonder.common.status.Status;
   import com.qiyi.player.wonder.plugins.tips.TipsDef;
   
   public class TipsProxy extends Proxy implements IStatus
   {
      
      public function TipsProxy(param1:Object = null) {
         super(NAME,param1);
         this._status = new Status(TipsDef.STATUS_BEGIN,TipsDef.STATUS_END);
         this._lagTimesArr = [];
         this._status.addStatus(TipsDef.STATUS_VIEW_INIT);
      }
      
      public static const NAME:String = "com.qiyi.player.wonder.plugins.tips.model.TipsProxy";
      
      private var _status:Status;
      
      private var _lagTimesArr:Array;
      
      private var _isFocusFirstTips:Boolean = false;
      
      private var _isFocusSecondTips:Boolean = false;
      
      private var _needCheckDirectPageShowPPTip:Boolean = true;
      
      public function get needCheckDirectPageShowPPTip() : Boolean {
         return this._needCheckDirectPageShowPPTip;
      }
      
      public function set needCheckDirectPageShowPPTip(param1:Boolean) : void {
         this._needCheckDirectPageShowPPTip = param1;
      }
      
      public function get status() : Status {
         return this._status;
      }
      
      public function addStatus(param1:int, param2:Boolean = true) : void {
         if(param1 >= TipsDef.STATUS_BEGIN && param1 < TipsDef.STATUS_END && !this._status.hasStatus(param1))
         {
            if(param1 == TipsDef.STATUS_OPEN && !this._status.hasStatus(TipsDef.STATUS_VIEW_INIT))
            {
               this._status.addStatus(TipsDef.STATUS_VIEW_INIT);
               sendNotification(TipsDef.NOTIFIC_ADD_STATUS,TipsDef.STATUS_VIEW_INIT);
            }
            this._status.addStatus(param1);
            if(param2)
            {
               sendNotification(TipsDef.NOTIFIC_ADD_STATUS,param1);
            }
         }
      }
      
      public function removeStatus(param1:int, param2:Boolean = true) : void {
         if(param1 >= TipsDef.STATUS_BEGIN && param1 < TipsDef.STATUS_END && (this._status.hasStatus(param1)))
         {
            this._status.removeStatus(param1);
            if(param2)
            {
               sendNotification(TipsDef.NOTIFIC_REMOVE_STATUS,param1);
            }
         }
      }
      
      public function hasStatus(param1:int) : Boolean {
         return this._status.hasStatus(param1);
      }
      
      public function getHotChatTipsTimesByIndex(param1:uint) : Boolean {
         switch(param1)
         {
            case 0:
               return this._isFocusFirstTips;
            case 1:
               return this._isFocusSecondTips;
            default:
               return true;
         }
      }
      
      public function setHotChatTipsTimesByIndex(param1:uint) : void {
         switch(param1)
         {
            case 0:
               this._isFocusFirstTips = true;
               break;
            case 1:
               this._isFocusSecondTips = true;
               break;
         }
      }
      
      public function clearHotChatTipsTimes() : void {
         this._isFocusSecondTips = false;
         this._isFocusFirstTips = false;
      }
      
      public function lag(param1:int) : Boolean {
         var _loc2_:uint = new Date().time;
         this._lagTimesArr.push(_loc2_);
         var _loc3_:* = 0;
         while(_loc3_ < this._lagTimesArr.length)
         {
            if(_loc2_ - this._lagTimesArr[_loc3_] > param1)
            {
               this._lagTimesArr.splice(_loc3_,1);
            }
            _loc3_++;
         }
         if(this._lagTimesArr.length >= TipsDef.MAX_STUCK)
         {
            this._lagTimesArr.length = 0;
            return true;
         }
         return false;
      }
   }
}
